package deprecated;

import test.fingers.R;
import test.fingers.R.id;
import test.fingers.R.layout;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.SeekBar;
import android.widget.TextView;

public class GameInit extends Activity{
	private int numHumans, numComp;
	private SeekBar humanSeekBar, compSeekBar;

	public void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
		setContentView(R.layout.gameinit);

		initVariables(); //sets up some variables

		//deals with actions on the human seek bar
		humanSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener(){
			public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser){
				numHumans = progress + 1;
				((TextView) findViewById(R.id.numHumansText)).setText(Integer.toString(numHumans));
				//compSeekBar.setMax(5 - numHumans);
				if(numHumans + numComp > 5){
					numComp = 5 - numHumans;
				}else if(numHumans == 1){
					numComp = 1;
				}else{
					return;
				}
				((TextView) findViewById(R.id.numCompText)).setText(Integer.toString(numComp));
				compSeekBar.setProgress(numComp);
			}

			public void onStartTrackingTouch(SeekBar seekBar){}

			public void onStopTrackingTouch(SeekBar seekBar){}
		});

		//deals with actions o nthe computer seek bar
		compSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener(){
			public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser){
				if(numHumans + progress > 5){
					numComp = 5 - numHumans;
				}else if(numHumans == 1 && progress == 0){
					numComp = 1;
				}else{
					numComp = progress;
				}
				((TextView) findViewById(R.id.numCompText)).setText(Integer.toString(numComp));
				compSeekBar.setProgress(numComp);
			}

			public void onStartTrackingTouch(SeekBar seekBar){}

			public void onStopTrackingTouch(SeekBar seekBar){}
		});
		
		// this sets up a click listener for the continue button
		findViewById(R.id.gameInitContButton).setOnClickListener(
				new View.OnClickListener() {
					public void onClick(View v) {
						goToDeal();
					}
				});
	}

	private void initVariables(){
		numHumans = 1;
		numComp = 1;

		humanSeekBar = ((SeekBar) findViewById(R.id.humanSeekBar));
		compSeekBar = ((SeekBar) findViewById(R.id.compSeekBar));
	}
	
	//this should switch to the init screen where you select number of players
	private void goToDeal() {
		Intent i = new Intent(this, Deal.class);
		startActivity(i);
	}
}
